package _3sort.src;

public class _2SelectionSort {
    public static void main(String[] args) {
        long startTime = System.nanoTime();

        int[] arr = new int[]{5, 8, 6, 3,4, 9, 2, 1, 7};
        for (int i = 0; i < arr.length-1; i++) {
            int minIndex=i;
            for (int j = i + 1; j < arr.length; j++) {
                if (arr[minIndex] >arr[j]) {
                    minIndex = j;
                }
            }
            if (i != minIndex){
                int tempNumber = arr[i];
                arr[i] = arr[minIndex];
                arr[minIndex]=tempNumber;
            }
        }
        for (int i : arr) {
            System.out.print(i+" ");
        }

        long endTime = System.nanoTime();
        System.out.println("耗时：" + (endTime - startTime) + " ns");
        System.out.println("耗时：" + (endTime - startTime) / 1_000_000.0 + " ms");
    }
}
